import Vue from 'vue'
const methods = Vue.mixin({
  data () {
    return {
      islogin: sessionStorage.getItem("userinfo") || '',
      defaultImg: 'this.src="' + require("../image/pic8.png") + '"',
      // clientWidth: 1920
    }
  },
  watch: {
    // clientWidth (val) {//监控浏览器宽度变化
    //   if (!this.timer) {
    //     this.clientWidth = val
    //     this.timer = true
    //     let that = this
    //     setTimeout(function () {
    //       that.timer = false
    //     }, 400)
    //   }

    // }
  },
  mounted () {
    // this.clientWidth = document.body.clientWidth
    // this.get_bodyHeight()
  },
  methods: {
    // get_bodyHeight () {//动态获取浏览器高度
    //   const that = this
    //   window.onresize = () => {
    //     console.log("555555555555555555555", document.body.clientWidth);
    //     that.clientWidth = document.body.clientWidth
    //   }
    // },
    goback () {
      this.$router.back();
    },
    tourl (url, flag = false) {
      if (url.indexOf("http") >= 0) {
        location.href = url
      } else {
        let flags = flag || false;
        this.$router.isBack = flags;
        this.$router.push(url);
      }
    }
  }
})
const directives = Vue.directive('focus', {
  inserted: function (el) {
    el.focus();
  }
})
export {
  methods,
  directives
}
